#ifndef RP2TSHAREDARRAY_H
#define RP2TSHAREDARRAY_H

#include "Rp2Object.h"

namespace Rp2
{

template <class T>
class TSharedArray : public Object
{
public:
	TSharedArray(int iQuantity = 0, T* atArray = 0);
	TSharedArray(const TSharedArray& rkShared);
	virtual ~TSharedArray();

	// copy constructor
	TSharedArray& operator= (const TSharedArray& rkShared);

	// member access
	int GetQuantity() const;
	T* GetData() const;
	operator const T* () const;
	operator T* ();
	const T& operator[] (int i) const;
	T& operator[] (int i);

    // This will not cause a reallocation of the array.  The idea is to
    // allow only some of the data to be considered valid.  The caller is
    // responsible for remembering the total quantity that was passed to the
    // constructor.
	void SetActiveQuantity(int iActiveQuantity);

protected:
	int m_iQuantity;
	T* m_atArray;
};

#include "Rp2TSharedArray.inl"

}

#endif